using System.Collections.Generic;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;

namespace System
{
	public class SerializableDictionary<TKey, TValue> : Dictionary<TKey, TValue>, IXmlSerializable
	{
		public SerializableDictionary()
		{
		}

		public XmlSchema GetSchema()
		{
			return null;
		}

		public void ReadXml(XmlReader reader)
		{
			reader.Read();
			XmlSerializer xmlSerializer = new XmlSerializer(typeof(TKey));
			XmlSerializer xmlSerializer1 = new XmlSerializer(typeof(TValue));
			while (reader.NodeType != XmlNodeType.EndElement)
			{
				reader.ReadStartElement("Item");
				reader.ReadStartElement("key");
				TKey tKey = (TKey)xmlSerializer.Deserialize(reader);
				reader.ReadEndElement();
				reader.ReadStartElement("value");
				TValue tValue = (TValue)xmlSerializer1.Deserialize(reader);
				reader.ReadEndElement();
				reader.ReadEndElement();
				Add(tKey, tValue);
				reader.MoveToContent();
			}
			reader.ReadEndElement();
		}

		public void WriteXml(XmlWriter writer)
		{
			XmlSerializer xmlSerializer = new XmlSerializer(typeof(TKey));
			XmlSerializer xmlSerializer1 = new XmlSerializer(typeof(TValue));
			foreach (KeyValuePair<TKey, TValue> keyValuePair in this)
			{
				writer.WriteStartElement("Item");
				writer.WriteStartElement("key");
				xmlSerializer.Serialize(writer, keyValuePair.Key);
				writer.WriteEndElement();
				writer.WriteStartElement("value");
				xmlSerializer1.Serialize(writer, keyValuePair.Value);
				writer.WriteEndElement();
				writer.WriteEndElement();
			}
		}
	}
}